home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-02 | 4.0 KB | 158 lines | [TEXT/MPS ] |
- {
- COPYRIGHT (C) 1984-1990 Apple Computer,Inc.
- All rights reserved
- }
-
- UNIT IconPick;
-
- { Icon Resource Picker }
-
- { This is the Icon resource picker. This picker is very similar to all other pickers.
- The general scheme is that a List structure is created whose cells
- contain the ID's of this resource type. A drawproc is installed in the List
- record which is called to display the resource. Obviously, graphical resources
- are drawn as is, but descriptions of other types can be displayed also (usually
- in a one-dimensional list). }
-
- INTERFACE
-
- USES MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
- ResEd;
-
- PROCEDURE EditBirth(thing: Handle; dad: ParentHandle);
- PROCEDURE PickBirth(t: ResType; dad: ParentHandle);
- PROCEDURE DoEvent(VAR evt: EventRecord; pick: PickHandle);
- PROCEDURE DoInfoUpdate(oldID, newID: INTEGER; pick: PickHandle);
- FUNCTION IsThisYours (thing: Handle; pick: PickHandle): BOOLEAN;
- PROCEDURE DoMenu(menu, item: INTEGER; pick: PickHandle);
-
- IMPLEMENTATION
-
- CONST
- listCellSizeH = $38;
- listCellSizeV = $42;
-
- { Needs to be 2 wide so that I can always tell a 2d list from a normal text list. }
- minIconsPerRow = 2;
- ICONMinWindowWidth = (minIconsPerRow * listCellSizeH) + theScrollBar;
- ICONMinWindowHeight = listCellSizeV;
-
- ICONResourceSize = 128;
-
- {$R-}
-
- PROCEDURE EditBirth(thing: Handle; dad: ParentHandle);
-
- BEGIN
- END;
-
- { *********************************************************************************** }
-
- { Returns the width and the iconsPerRow. }
- FUNCTION GetWidth (VAR iconsPerRow: INTEGER): INTEGER;
-
- VAR
- width: INTEGER;
-
- BEGIN
- width := PickStdWidth;
- IF width > ICONMinWindowWidth THEN
- BEGIN
- iconsPerRow := (width - theScrollBar) DIV listCellSizeH;
- width := (iconsPerRow * listCellSizeH) + theScrollBar;
- END
- ELSE
- BEGIN
- width := ICONMinWindowWidth;
- iconsPerRow := minIconsPerRow;
- END;
- GetWidth := width;
- END;
-
- { *********************************************************************************** }
-
- FUNCTION GetHeight: INTEGER;
-
- VAR
- height: INTEGER;
-
- BEGIN
- height := PickStdHeight;
- IF height > ICONMinWindowHeight THEN
- height := (height DIV listCellSizeV) * listCellSizeV
- ELSE
- height := ICONMinWindowHeight;
- GetHeight := height;
- END;
-
- { *********************************************************************************** }
-
- PROCEDURE PickBirth(t: ResType; dad: ParentHandle);
-
- VAR
- pick: PickHandle;
- iconsPerRow, width: INTEGER;
-
- BEGIN
- pick := PickHandle(NewHandle(SIZEOF(PickRec)));
-
- WITH pick^^ DO
- BEGIN
- father := dad; { Back ptr to dad }
- rType := t; { Resource type }
- viewBy := viewBySpecial;
- ldefType := t;
- cellSize.h := listCellSizeH;
- cellSize.v := listCellSizeV;
- END;
- width := GetWidth (iconsPerRow); { Also sets iconsPerRow }
- IF NOT DoPickBirth(FALSE, TRUE, width, GetHeight, iconsPerRow, ResEdId, pick) THEN
- DisposHandle (Handle(pick))
- ELSE
- pick^^.rSize := ICONResourceSize;
- END;
-
- { *********************************************************************************** }
-
- { Everything except the grow box is taken care of for us by PickEvent.}
- PROCEDURE DoEvent(VAR evt: EventRecord; pick: PickHandle);
-
- VAR
- windPtr: WindowPtr;
-
- BEGIN
- { Must do our own grow box manipulation so that the min size is set correctly. }
- IF (evt.what = mouseDown) & (FindWindow(evt.where, windPtr) = inGrow) THEN
- GrowMyWindow (ICONMinWindowWidth, ICONMinWindowHeight, windPtr, pick^^.instances)
- ELSE
- PickEvent(evt, pick);
- END;
-
- { *********************************************************************************** }
-
- { Everything is taken care of for us by PickInfoUp }
- PROCEDURE DoInfoUpdate(oldID, newID: INTEGER; pick: PickHandle);
-
- BEGIN
- PickInfoUp(oldID, newID, pick);
- END;
-
- { *********************************************************************************** }
-
- FUNCTION IsThisYours (thing: Handle; pick: PickHandle): BOOLEAN;
-
- BEGIN
- IsThisYours := FALSE;
- END;
-
- { *********************************************************************************** }
-
- PROCEDURE DoMenu(menu, item: INTEGER; pick: PickHandle);
-
- BEGIN
- { Everything is taken care of for us by PickMenu. }
- PickMenu(TRUE, menu, item, pick); { Do the normal picker stuff. }
- END;
-
- END.
-